package com.guigu.liuyunan.controller;

import com.guigu.liuyunan.pojo.Ordersetting;
import com.guigu.tankai.service.OrderSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@RestController
@RequestMapping("LYN")
public class OrderSettingController {

    @Autowired
    OrderSettingService os;

    @PostMapping("orderSettingInfo")
    public Ordersetting OrderSettingInfo(@RequestBody Ordersetting ordersetting){
        return os.OrderSettingInfo(ordersetting);
    }

    @GetMapping("yyorderSetting")
    public Ordersetting yyorderSetting(String date) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = simpleDateFormat.parse(date);
        Calendar calendar = Calendar.getInstance();
        long d =  date1.getTime()+1*24*3600*1000;
        calendar.setTimeInMillis(d);
        return os.yyorderSetting(simpleDateFormat.format(calendar.getTime()));
    }



    @PostMapping("UpAndAddOrderSetting")
    public int UpAndAddOrderSetting(@RequestBody Ordersetting ordersetting){
        return os.UpAndAddOrderSetting(ordersetting);
    }

}
